import { CORE_APP_LIST, CORE_RULE_LIST } from '@/config/api'
import setupMock, { successResponseWrap } from '@/utils/setup-mock'
import Mock, { Random } from 'mockjs'

setupMock({
    setup() {
        // 应用列表
        Mock.mock(new RegExp(CORE_APP_LIST), () => {
            const arr = Mock.mock({
                'array|1-5': [
                    {
                        id: '@id',
                        name: '@cname',
                        'type|+1': ['web', 'app', 'wechat', 'server'],
                        'state|+1': [0, 1],
                        remark: '@cparagraph'
                    }
                ]
            })
            return successResponseWrap(arr.array)
        })

        // 规则列表
        Mock.mock(new RegExp(CORE_RULE_LIST), () => {
            const arr = Mock.mock({
                'array|1-5': [
                    {
                        'id|+1': Random.integer(1, 9999),
                        name: '@cname',
                        'type|+1': ['string', 'boolean'],
                        field: '@first',
                        'sort|+1': Random.integer(1, 9999)
                    }
                ]
            })
            return successResponseWrap(arr.array)
        })
    }
})
